<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="keywords" content="易飞出行,易飞卡,易行卡,易飞闪付,易飞饭票,机场贵宾厅,高铁贵宾,机场vip服务,机场吃饭,礼宾车,机场贵宾,机场vip服务,机场vip卡,候机,高铁休息室,高铁vip,机场贵宾购买,机场贵宾服务,要客通" />
    <meta name="description" content="欢迎访问易飞出行官网，行有乐智未来、美好的一天从易飞出行开始！" />
    <title>易飞出行</title>
    <link rel="shortcut icon" href="${ctx}/favicon.ico"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/lib/andrew/css/style.css" />
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/lib/andrew/css/andrew.pc.plugin.css" />
    <script type="text/javascript" src="${ctx}/resources/lib/andrew/js/jquery.js"></script>
    <!--[if lte IE 8]>
    <script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
    <![endif]-->
    <script type="text/javascript" src="${ctx}/resources/lib/andrew/js/data.js"></script>
    <script type="text/javascript" src="${ctx}/resources/lib/andrew/js/andrew.pc.plugin.js"></script>
</head>
<body>
<!--[if lte IE 7]>
<div class="bg_title_sub fix w_100 h_100 c_white text_al_c zindex_show left_0 top_0 pt_5 text_24em">hi、您当前的浏览器版本过低、可能存在安全风险、建议升级浏览器后访问！</div>
<![endif]-->
<section class="ovh w_100 bg_title bor_top bor_white">
    <div class="wrap clear c_white line_h_3em">
        <i class="iconfont icon-dingwei"></i> 直拼机 > 微信支付
    </div>
</section>
<main>
    <section class="clear w_100 mt_2em mb_2em">
        <div class="wrap">
            <div class="w_100 ovh bg_title_tint">
                <h3 class="fl line_h_3em pl_3 c_title text_14em">微信支付</h3>
                <span class="fl ml_1em c_gray_777 line_h_42em">距离二维码失效还剩<em class="c_close plug_countdown"></em>，过期后请重新获取二维码(如果您已支付成功，但页面未跳转，请您到“我的订单”中查看是否支付成功)。</span>
            </div>
            <form class="" action="#" onsubmit="return false">
                <div class="ovh press bg_white mt_1em border bor_gray_ddd">
                    <ul class="ovh mt_3 mb_1em">
                        <li class="ovh rel fl w_60">
                            <figure class="dis_block rel ovh pa_3 bor_gray_ddd border w_40 center">
                                <button type="button" class="dis_none abs left_0 top_0 w_100 h_100 bg_black07 c_white"><i class="iconfont icon-shuaxin text_bold c_white text_4em dis_block"></i><em class="dis_block mt_2em">该二维码已失效</em></button>
                              <img src="${ctx}/${qrcodeUrl}" onerror="onerror=null;src='${ctx}/upload/img/qrcode/invalid.jpg'" class="w_100"/> 
                            </figure>
                            <button class="mt_2em btn_max w_40 center text_12em bg_orange c_white">请使用微信扫一扫，扫描二维码支付</button>
                        </li>
                        <li class="ovh rel fl text_al_c">
                            <img src="${ctx}/resources/lib/andrew/img/qrcode_weixin.jpg" class="w_100"/>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
    </section>
</main>
<footer class="w_100 bor_top bor_gray_ddd ovh bottom_0 fix">
	<div class="wrap text_al_c pa_2 c_gray_777 text_12em line_h_16em">
	      <p>©2017 青岛直拼机网络科技有限公司 京公网安备11000002002025号</p>
	      <p>京ICP备12043664号-5　京ICP证150329号 京网文【2015】2410-473</p>
	</div>
</footer>
<script type="text/javascript">
$(function() {
	//二维码初始化
	var time = 5;
	if('ERROR'=='${qrcodeUrl}'){
		alert('您的订单数据异常，无法获取微信支付二维码，请联系管理员！')
		time = 0;
	}
	$(".plug_countdown").each(function () {
	    Andrew_CountDown($(this),{
	        wait: time, //默认秒数
	        Start_text: "秒", //倒计时开始文字
	        End_Text: "0秒", //倒计时结束后的文字
	        callback:function(waits){ //回调
	          $("form").find("figure").children("button").removeClass("dis_none");
	          $("form").find("figure").children("img").attr("src","${ctx}/upload/img/qrcode/invalid.jpg?dt="+new Date());
	        }
	    });
	});
	//失效是二维码点击事件
	$("form").find("figure").children("button").click(function() {
		var that = $(this);
	    $(this).find("em").text("加载中...");
	    var data = {};
	    data.qrocodeImName = '${qrcodeImgName}';
	    data.outTradeNo = '${outTradeNo}';
	    data.totalFee = '${totalFee}';
	    data.body = '${body}';
	    data.productId = '${productId}';
	    data.ip = '${ip}';
	 	$.ajax({
			cache : false,
			type : 'POST',
			url : "${ctx}/pay/open/wxPayToRefreshQRCode",
			data : data,
			success : function(res) {
				if(res.status){
				   	that.addClass("dis_none");
					that.find("em").text("该二维码已失效");
					that.next("img").attr("src","${ctx}/"+res.data+"?dt="+new Date());
					$(".plug_countdown").each(function () {
				        Andrew_CountDown($(this),{
				            wait: 60, //默认秒数
				            Start_text: "秒", //倒计时开始文字
				            End_Text: "0秒", //倒计时结束后的文字
				            callback:function(waits){ //回调
				              $("form").find("figure").children("button").removeClass("dis_none");
				              $("form").find("figure").children("img").attr("src","${ctx}/upload/img/qrcode/invalid.jpg?dt="+new Date());
				            }
				        });
				    });
				}else{
					that.find("em").text("获取数据失败，请重新尝试！");
				}
	
			},
			error : function(err) {
				that.find("em").text("获取数据失败，请重新尝试！");
				//请求失败处理函数
				webToast("请求错误", "middle", "mask", 1000);
			}
		}); 
	});
	//轮询查看该订单是否支付成功
	setInterval(function() {
		var data = {};
		data.outTradeNo = '${outTradeNo}';
		$.ajax({
			cache : false,
			type : 'POST',
			url : "${ctx}/pay/open/wxPayIsSucceed",
			data : data,
			success : function(res) {
				if(res.status){
					var returnUrl = '${returnUrl}'.replace("#","%23");
					window.location.href = "${ctx}/pay/open/wxScanQRCodeSuccessPage?outTradeNo=${outTradeNo}&returnUrl="+returnUrl;
				}
			},
			error : function(err) {
				//请求失败处理函数
				webToast("请求错误", "middle", "mask", 1000);
			}
		}); 
	},3000);
})
/* function check() {
	var data = {};
	data.outTradeNo = "${outTradeNo}";
	console.log(data);
 	$.ajax({
		cache : false,
		type : 'POST',
		url : "${ctx}/frontPage/passOrder/wxPayIsSucceed",
		data : data,
		success : function(data) {
			if("200"==data.statusCode){
				var action = "${ctx}/frontPage/passOrder/wxPayOk.html";
				var body = $("body"); 
			    // 创建Form  
			    var form = $('<form id="wxpayok"></form>');  
			    body.append(form);
			    // 设置属性  
			    form.attr('action', action);  
			    form.attr('method', 'post');  
			    // form的target属性决定form在哪个页面提交  
			    // _self -> 当前页面 _blank -> 新页面  
			    form.attr('target', '_self');  
			    // 创建Input  
			    var wxpay_content = $('<input type="hidden" name="wxpay_content" />');  
			    wxpay_content.attr('value', '${wxpay_content}');  
			    // 附加到Form  
			    form.append(wxpay_content); 
			    form.submit();
			}
			if("300"==data.statusCode){
				switch (data.result) {
    			//用户控制码
				case 13:
				case 14:
				case 19:
					if(!$("#login_dialog_plug_popupWin.bounceInDown")){
						Andrew_Popupwin({
				            dom: "#login_dialog_plug_popupWin", //弹窗内容的布局
				            position: "middle", //位置类型(top，bottom，left，right，middle)
				            effectIn: "bounceInDown", //弹窗显示效果
				            effectOut: "bounceOutDown", //弹窗消失效果
				            maskPosition:"11", //Mask的z-index数值
				            closeBtn: ".login_dialog_plugin_close" //关闭弹窗按钮
				        })
					}
					break;
					//异常码
				case 4:
					webToast(data.message,"bottom","mask",5000);
					break;
				//业务错误码
				case -1:
					break;
				case -2:
					webToast(data.message,"bottom","mask",5000);
					setTimeout("javascript:location.href='${ctx}/frontPage/passIndex/index.html'", 3000); 
					break;
				case -3:
					$("form").find("figure").children("button").removeClass("dis_none");
					$("form").find("figure").children("button").find("em").text("订单超时关闭");
					$("form").find("figure").children("button").next("img").attr("src","${ctx}/upload/img/qrcode/invalid.jpg?dt="+new Date());
					break;
				}
			}
		},
		error : function(err) {
			//请求失败处理函数
			webToast("请求错误", "middle", "mask", 1000);
		}
	}); 
};
$(function() {
	var time = 60;
	if('true'=='${outDateFlag}'){
		$("form").find("figure").children("button").removeClass("dis_none");
		$("form").find("figure").children("button").find("em").text("订单超时关闭");
		$("form").find("figure").children("button").next("img").attr("src","${ctx}/upload/img/qrcode/invalid.jpg?dt="+new Date());
		time = 0;
	}else{
		var img_src = $("form").find("figure").children("button").next("img").attr("src")+"?dt123="+new Date();
		$("form").find("figure").children("button").next("img").attr("src",img_src);
		time = 60;
	}
	//setInterval(check,3000);
	$(".plug_countdown").each(function () {
        Andrew_CountDown($(this),{
            wait: time, //默认秒数
            Start_text: "秒", //倒计时开始文字
            End_Text: "0秒", //倒计时结束后的文字
            callback:function(waits){ //回调
              $("form").find("figure").children("button").removeClass("dis_none");
              $("form").find("figure").children("img").attr("src","${ctx}/upload/img/qrcode/invalid.jpg?dt="+new Date());
            }
        });
    });
	$("form").find("figure").children("button").click(function() {
		var that = $(this);
		var body = $("body"); 
		var action = "${ctx}/frontPage/passOrder/wxPayToRefreshQRCode";
	    // 创建Form  
	    var form = $('<form id="wxpay"></form>');  
	    body.append(form);
	    // 设置属性  
	    form.attr('action', action);  
	    form.attr('method', 'post');  
	    // form的target属性决定form在哪个页面提交  
	    // _self -> 当前页面 _blank -> 新页面  
	    form.attr('target', '_self');  
	    // 创建Input  
	    var wxpay_content = $('<input type="hidden" name="wxpay_content" />');  
	    wxpay_content.attr('value', '${wxpay_content}');  
	    // 附加到Form  
	    form.append(wxpay_content); 
	    $(this).find("em").text("加载中...");
		$.ajax({
			cache : false,
			type : 'POST',
			url : action,
			data : $("#wxpay").serialize(),
			success : function(data) {
				$("#wxpay").remove();
				if("200"==data.statusCode){
					that.addClass("dis_none");
					that.find("em").text("该二维码已失效");
					that.next("img").attr("src","${ctx}/"+data.result+"?dt="+new Date());
					$(".plug_countdown").each(function () {
				        Andrew_CountDown($(this),{
				            wait: 60, //默认秒数
				            Start_text: "秒", //倒计时开始文字
				            End_Text: "0秒", //倒计时结束后的文字
				            callback:function(waits){ //回调
				              $("form").find("figure").children("button").removeClass("dis_none");
				              $("form").find("figure").children("img").attr("src","${ctx}/upload/img/qrcode/invalid.jpg?dt="+new Date());
				            }
				        });
				    });
				}
				if("300"==data.statusCode){
					that.removeClass("dis_none");
					that.find("em").text("请求失败，请重新尝试");
					switch (data.result) {
	    			//用户控制码
					case 13:
					case 14:
					case 19:
						 Andrew_Popupwin({
					            dom: "#login_dialog_plug_popupWin", //弹窗内容的布局
					            position: "middle", //位置类型(top，bottom，left，right，middle)
					            effectIn: "bounceInDown", //弹窗显示效果
					            effectOut: "bounceOutDown", //弹窗消失效果
					            maskPosition:"11", //Mask的z-index数值
					            closeBtn: ".login_dialog_plugin_close" //关闭弹窗按钮
					        })
						break;
						//异常码
					case 4:
						webToast(data.message,"bottom","mask",5000);
						break;
					case -1:
						that.removeClass("dis_none");
						that.find("em").text("订单超时关闭");
						that.next("img").attr("src","${ctx}/upload/img/qrcode/invalid.jpg?dt="+new Date());
						break;
					//业务错误码
					}
				}
			},
			error : function(err) {
				that.removeClass("dis_none");
				that.find("em").text("请求失败，请重新尝试");
				$("#wxpay").remove();
				//请求失败处理函数
				webToast("请求错误", "middle", "mask", 1000);
			}
		});
	});
}); */
</script>
</body>
</html>